/*
* INSANE - Interactive Structural Analysis Environment
*
* Copyright (C) 2003-2006
* Universidade Federal de Minas Gerais
* Escola de Engenharia
* Departamento de Engenharia de Estruturas
* 
* Author's email :    insane@dees.ufmg.br
* Author's website :  http://www.dees.ufmg.br/insane
* 
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
package br.ufmg.dees.insane.continuousPointModel;

import java.io.Serializable;
import java.util.ArrayList;

import br.ufmg.dees.insane.util.IMatrix;
import br.ufmg.dees.insane.util.IVector;
import br.ufmg.dees.insane.util.geometricProperties.GeometricProperties;

/**
*A class representing an ReissnerMindlinPlatePoint analysis model.
*
*@author Samir
*@version 1.0
*@since 19/09/2006
*/
public class ReissnerMindlinPlatePoint implements ContinuousPointModel, Serializable  {

	private static final long serialVersionUID = 1L;

	/* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getInternalVariableOperator(br.ufmg.dees.insane.util.IMatrix, br.ufmg.dees.insane.util.IVector, br.ufmg.dees.insane.util.IMatrix)
     */
    public IMatrix getInternalVariableOperator(IMatrix d, IMatrix d2, IVector n, IMatrix c) {
        IMatrix l = new IMatrix(5,5);
        l.setZero();
        l.setElement(0,0,c.getElement(2,0));
        l.setElement(1,1,c.getElement(2,0));
        l.setElement(2,2,c.getElement(2,0));
        l.setElement(3,3,1);
        l.setElement(4,4,1);
        return l;
    }

    /* (non-Javadoc)
     * @see lr.ufmg.dees.insane.analysisModel.AnalysisModel#getInternalVarialleOperator(lr.ufmg.dees.insane.util.IMatrix, lr.ufmg.dees.insane.util.IVector, lr.ufmg.dees.insane.util.IMatrix, lr.ufmg.dees.insane.util.IMatrix)
     */
    public IMatrix getInternalVariableOperator(IMatrix d, IMatrix d2, IVector n, IMatrix c,
            IMatrix u) {
        IMatrix l = new IMatrix(5,5);
        l.setZero();
        l.setElement(0,0,c.getElement(2,0));
        l.setElement(1,1,c.getElement(2,0));
        l.setElement(2,2,c.getElement(2,0));
        l.setElement(3,3,1);
        l.setElement(4,4,1);
        return l;
   }
    
     /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#modifyInternalVariableOperator(br.ufmg.dees.insane.util.IMatrix, br.ufmg.dees.insane.util.IMatrix)
     */
    public IMatrix modifyInternalVariableOperator(IMatrix e, IMatrix m) {
        return e;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getDualInternalVariableOperator(br.ufmg.dees.insane.util.IMatrix)
     */
    public IMatrix getDualInternalVariableOperator(IMatrix e) {
    	IMatrix d = new IMatrix(5,5);
		d.setZero();
		double Ex = e.getElement(0,0);
		double Ey = e.getElement(1,1);
		double vxy = e.getElement(0,1);
		double vyx = e.getElement(1,0);
		double Gxy = e.getElement(3,3);
		double Gxz = e.getElement(4,4);
		double Gyz = e.getElement(5,5);
		double k = (1/(1-(vxy*vyx)));
		
		d.setElement(0,0,(k*Ex));
		d.setElement(0,1,(k*vxy*Ex));
		d.setElement(1,0,(k*vyx*Ex));
		d.setElement(1,1,(k*Ey));
		d.setElement(2,2,(k*(1-(vyx*vxy))*Gxy));
		
		d.setElement(3,3,(5*Gxz/6));
		d.setElement(4,4,(5*Gyz/6));
		return(d); 
    }
    
    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#modifyDualInternalVariableOperator(br.ufmg.dees.insane.util.IMatrix, java.util.ArrayList)
     */
	public IMatrix modifyDualInternalVariableOperator(IMatrix e, GeometricProperties gps)	{
		return e;
	}
    
    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getNumberOfInternalVariables()
     */
    public int getNumberOfInternalVariables(){
    	return 5; 
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getNumberOfDualInternalVariables()
     */
    public int getNumberOfDualInternalVariables(){
    	return 5; 
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getInternalVariablesVector(br.ufmg.dees.insane.util.IVector, br.ufmg.dees.insane.util.IMatrix)
     */
    public IVector getInternalVariablesVector(IVector a, IMatrix b){    	
		return a; 
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getInternalDualVariablesVector(br.ufmg.dees.insane.util.IVector, br.ufmg.dees.insane.util.IMatrix)
     */
    public IVector getDualInternalVariablesVector(IVector a, IMatrix b){
    	return a;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getInternalVariablesTensor(br.ufmg.dees.insane.util.IVector, br.ufmg.dees.insane.util.IMatrix)
     */
     public IMatrix getInternalVariablesTensor(IVector a, IMatrix b){
         return expandTensor(a);	
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getInternalDualVariablesTensor(br.ufmg.dees.insane.util.IVector, br.ufmg.dees.insane.util.IMatrix)
     */
    public IMatrix getDualInternalVariablesTensor(IVector a, IMatrix b){
        return expandTensor(a);
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getInternalVariablesDirLabels()
     */
    public String[] getInternalVariablesLabels() {
        String[] Dlabels = {"EPSILONxx", "EPSILONyy", "EPSILONxy", "GAMAxz", "GAMAyz"};
        return Dlabels;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#getDualInternalVariablesDirLabels()
     */
    public String[] getDualInternalVariablesLabels() {
        String[] Dlabels = {"SIGMAxx", "SIGMAyy", "TAUxy", "TAUxz", "TAUyz"};
        return Dlabels;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#expandVector(br.ufmg.dees.insane.util.IVector)
     */
    public IVector expandVector(IVector a){
    	IVector Vector = new IVector(6);
        Vector.setElement(0,a.getElement(0));
        Vector.setElement(1,a.getElement(1));
        Vector.setElement(2,a.getElement(2));
        Vector.setElement(3,a.getElement(3));
        Vector.setElement(4,a.getElement(4));
        return Vector;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#expandTensor(br.ufmg.dees.insane.util.IVector)
     */
    public IMatrix expandTensor(IVector a){
    	IMatrix Tensor = new IMatrix(3,3);
    	Tensor.setZero();
        Tensor.setElement(0,0,a.getElement(0));
        Tensor.setElement(0,1,a.getElement(2));
        Tensor.setElement(0,2,a.getElement(3));
        Tensor.setElement(1,0,a.getElement(2));
        Tensor.setElement(1,1,a.getElement(1));
        Tensor.setElement(1,2,a.getElement(4));
        Tensor.setElement(2,0,a.getElement(3));
        Tensor.setElement(2,1,a.getElement(4));
        return Tensor;
    }

    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#reduceVector(br.ufmg.dees.insane.util.IVector)
     */
    public IVector reduceVector(IVector a){
    	IVector Vector = new IVector(5);
        Vector.setElement(0,a.getElement(0));
        Vector.setElement(1,a.getElement(1));
        Vector.setElement(2,a.getElement(2));
        Vector.setElement(3,a.getElement(3));
        Vector.setElement(4,a.getElement(4));
        return Vector;
    }
    
    /* (non-Javadoc)
     * @see br.ufmg.dees.insane.analysisModel.AnalysisModel#reduceTensor(br.ufmg.dees.insane.util.IMatrix)
     */
    public IVector reduceTensor(IMatrix a){
    	IVector Vector = new IVector(5);
        Vector.setElement(0,a.getElement(0,0));
        Vector.setElement(1,a.getElement(1,1));
        Vector.setElement(2,a.getElement(0,1));
        Vector.setElement(3,a.getElement(0,2));
        Vector.setElement(4,a.getElement(1,2));
        return Vector;
    }

	public String getLabel() {
        return "ReissnerMindlinPlatePoint";
    }

	public int getDominion() {
		// TODO Auto-generated method stub
		return 0;
	}

	public double getIntegrationFactor(IVector n, IMatrix cN, GeometricProperties gps) {
		// TODO Auto-generated method stub
		return 0;
	}

	public ArrayList getDOFLabels(int n) {
		// TODO Auto-generated method stub
		return null;
	}
}
